<template>
  <div>
    <img id="captcha2" @click="refresh()" :src="capSrc" alt="验证码">
  </div>
</template>


<script>
import {baseUrl} from "../../network/baseUrl"

export default {
  name: "captcha",
  data(){
    return{
      baseUrl:baseUrl(),
      capSrc: baseUrl()+'/captcha/'+returnCitySN["cip"],
    }
  },
  created() {
    this.refresh()
  },
  methods:{
    refresh() { //验证码刷新
      let time=new Date()   //以当前时间为唯一值,防止缓存
      // let num = Math.ceil(Math.random() * 100000); //生成一个随机数（防止缓存）
      let url = baseUrl()+"/captcha"
      this.capSrc = url + '/' +returnCitySN["cip"]+'?'+time;
      console.log("验证码刷新成功!");

    },
  }
}
</script>

<style scoped>
#captcha2{
  cursor: pointer;
}
</style>